import React from 'react';
import { Modal } from 'antd';
import BaseForm from './baseForm'
export default class BaseModal extends React.Component {
  /**成功关闭弹出框 */
  handleOk = e => {
    this.refs.baseForm.refs.form.submit()
    // console.log('this.refs.baseForm.refs.form:', this.refs.baseForm.refs.form)
    const { closeModal } = this.props;
    closeModal && closeModal()
  };
  /**失败关闭弹出框 */
  handleCancel = e => {
    const { closeModal } = this.props;
    closeModal && closeModal(null)
  };

  getFormList = val => {
    const { closeModal } = this.props;
    closeModal && closeModal(val)
  }

  render() {
    const { formInfo, isEdit } = this.props;
    // console.log(this.props.formInfo, 'form')
    return (
      <div>
        <Modal
          title="Basic Modal"
          visible={this.props.visible}
          onOk={this.handleOk}
          onCancel={this.handleCancel}
        >
          <BaseForm
            isEdit={isEdit}
            ref="baseForm"
            getFormList={(val) => this.getFormList(val)}
            formInfo={formInfo}
          ></BaseForm>
        </Modal>
      </div>
    );
  }
}
